home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / APPBAR.ZIP / APPDLGS.C < prev    next >
C/C++ Source or Header  |  1993-06-04  |  6KB  |  221 lines

  1. #define STRICT
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <shellapi.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include "appbar.h"
  8.  
  9. /*************************************************************************/
  10. /*  FUNCTION: DlgAboutProc()                         */
  11. /*                                     */
  12. /*  WindowProc for the AboutBox                         */
  13. /*************************************************************************/
  14. BOOL WINAPI AboutDlgProc(HWND hDlgAbout, UINT message, WPARAM wParam, LPARAM lParam)
  15.     {
  16.     static HANDLE hLibrary;
  17.     HDC hDC;
  18.     RECT rc;
  19.     PAINTSTRUCT ps;
  20.  
  21.     switch(message)
  22.     {
  23.     case WM_INITDIALOG:
  24.         hLibrary = LoadLibrary("APPLIB.DLL");
  25.         hAppLogo = LoadBitmap(hLibrary, "AppLogo");
  26.         hNNever = LoadBitmap(hLibrary, "NNever");
  27.         return TRUE;
  28.  
  29.     case WM_PAINT:
  30.         hDC = BeginPaint(hDlgAbout, &ps);
  31.         rc = ps.rcPaint;
  32.         // draw two Bitmaps in the AboutBox
  33.         DrawBitmap(hDC, rc.left+4*cxChar, rc.top+cyChar, hAppLogo);
  34.         DrawBitmap(hDC, rc.left+3*cxChar, rc.top+cyChar*5, hNNever);
  35.         EndPaint(hDlgAbout, &ps);
  36.         return 0;
  37.  
  38.     case WM_COMMAND:
  39.         switch(wParam)
  40.         {
  41.         case IDOK:
  42.             FreeLibrary(hLibrary);
  43.             EndDialog(hDlgAbout, 0);
  44.             return TRUE;
  45.         }
  46.         break;
  47.     }
  48.     return FALSE;
  49.     } /* end DlgAboutProc */
  50.  
  51. /*************************************************************************/
  52. /*  FUNCTION: SystemDlgProc                         */
  53. /*                                     */
  54. /*  Dialog for the SystemButtonBar                     */
  55. /*************************************************************************/
  56. BOOL WINAPI SystemDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  57.     {
  58.     static DLGPROC lpfnAboutDlgProc, lpfnExitWDlgProc;
  59.  
  60.     switch(message)
  61.     {
  62.     case WM_INITDIALOG:
  63.         return TRUE;
  64.  
  65.     case WM_COMMAND:
  66.        if(HIWORD(lParam) == BN_CLICKED)
  67.         {
  68.         switch(wParam)
  69.             {
  70.             case ID_CLOSE:
  71.             if(!IsAppBarShell())
  72.                 {
  73.                 if(AppSound.EnableSound != 0)
  74.                 if(stricmp(AppSound.AppBarExit, "<none>") != 0)
  75.                     sndPlaySound(AppSound.AppBarExit, SND_ASYNC | SND_NODEFAULT);
  76.                 SendMessage(hWndMain, WM_COMMAND, WM_APPBAR_CLOSE, 0L);
  77.                 EndDialog(hDlg, TRUE);
  78.                 }
  79.             else
  80.                 {
  81.                 EndDialog(hDlg, TRUE);
  82.                 lpfnExitWDlgProc = (DLGPROC) MakeProcInstance((FARPROC)ExitWDlgProc, hInst);
  83.                 DialogBox(hInst, "ExitWDlg", hWndMain, lpfnExitWDlgProc);
  84.                 FreeProcInstance((FARPROC)lpfnExitWDlgProc);
  85.                 }
  86.             break;
  87.  
  88.             case ID_ABOUT:
  89.             lpfnAboutDlgProc = (DLGPROC) MakeProcInstance((FARPROC)AboutDlgProc, hInst);
  90.             DialogBox(hInst, "AboutDlg", hDlg, lpfnAboutDlgProc);
  91.             FreeProcInstance((FARPROC)lpfnAboutDlgProc);
  92.             EndDialog(hDlg, 0);
  93.             return TRUE;
  94.  
  95.             case ID_MOVE:    // Changes the window style to size it
  96.             EndDialog(hDlg, TRUE);
  97.             bMoveButton = TRUE;
  98.             SendMessage(hWndMain, (UINT) WM_LBUTTONDOWN, wParam, lParam);
  99.             break;
  100.  
  101.             case ID_SETUP:
  102.             EndDialog(hDlg, TRUE);
  103.             WinExec("appsetup.exe", SW_SHOWNORMAL);
  104.             break;
  105.  
  106.             case ID_RESTART:
  107.             EndDialog(hDlg, TRUE);
  108.             SendMessage(hWndMain, WM_COMMAND, WM_APPBAR_RESTART, 0L);
  109.             break;
  110.  
  111.             case ID_HELP:
  112.             EndDialog(hDlg, TRUE);
  113.             WinHelp(hWndMain,"appbar.hlp", HELP_CONTENTS, 0L);
  114.             break;
  115.  
  116.             case ID_MINIMIZE:
  117.             EndDialog(hDlg, TRUE);
  118.             bKeyboardOn = FALSE;
  119.             ShowWindow(hWndMain, SW_SHOWMINIMIZED);
  120.             break;
  121.  
  122.             case ID_INFRONT:
  123.             EndDialog(hDlg, TRUE);
  124.             if(AppSystem.StayInFront == 1)
  125.                 AppSystem.StayInFront = 0;
  126.             else
  127.                 AppSystem.StayInFront = 1;
  128.             break;
  129.  
  130.             case ID_QUICKLOAD:
  131.             bQuickLoad = !bQuickLoad;
  132.             if(!bQuickLoad)
  133.                 SetNormalChildCursor();
  134.             EndDialog(hDlg, TRUE);
  135.             InvalidateRect(hWndButton[0], NULL, FALSE);
  136.             UpdateWindow(hWndButton[0]);
  137.             return TRUE;
  138.  
  139.             case ID_CANCEL:
  140.             EndDialog(hDlg, 0);
  141.             return TRUE;
  142.             }
  143.         }
  144.        break; /* end WM_COMMAND */
  145.     }
  146.     return FALSE;
  147.     } /* end DlgSysProc */
  148.  
  149. /*-------------------------------------------------------------------------*/
  150. BOOL WINAPI ExitWDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  151.     {
  152.     switch(message)
  153.     {
  154.     case WM_INITDIALOG:
  155.         return TRUE;
  156.  
  157.     case WM_COMMAND:
  158.         switch(wParam)
  159.         {
  160.         case IDEXITW_YES:
  161.             EndDialog(hDlg, 0);
  162.             if(AppSound.EnableSound != 0)
  163.             if(stricmp(AppSound.WindowsExit, "<none>") != 0)
  164.                 sndPlaySound(AppSound.WindowsExit, SND_ASYNC | SND_NODEFAULT);
  165.             ExitWindows(NULL, NULL);
  166.             return TRUE;
  167.  
  168.         case IDEXITW_RESTART:
  169.             EndDialog(hDlg, 0);
  170.             if(AppSound.EnableSound != 0)
  171.             if(stricmp(AppSound.WindowsExit, "<none>") != 0)
  172.                 sndPlaySound(AppSound.WindowsExit, SND_ASYNC | SND_NODEFAULT);
  173.             ExitWindows(EW_RESTARTWINDOWS, NULL);
  174.             return TRUE;
  175.  
  176.         case IDEXITW_NO:
  177.             EndDialog(hDlg, 0);
  178.             InvalidateRect(hWndMain, NULL, NULL);
  179.             return TRUE;
  180.         }
  181.         break;
  182.     }
  183.     return FALSE;
  184.     }
  185.  
  186. /*-------------------------------------------------------------------------*/
  187. BOOL WINAPI AskDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  188.     {
  189.     switch(message)
  190.     {
  191.     case WM_INITDIALOG:
  192.         return TRUE;
  193.  
  194.     case WM_COMMAND:
  195.         switch(wParam)
  196.         {
  197.         case IDASK_PARAMS:
  198.             if(HIWORD(lParam) == EN_KILLFOCUS)
  199.             {
  200.             GetDlgItemText(hDlg, IDASK_PARAMS, szBuffer, MAXFILECHARS-1);
  201.             SetDlgItemText(hDlg, IDRUN_PROGRAM, szBuffer);
  202.             }
  203.             return TRUE;
  204.  
  205.         case IDASK_OK:
  206.             GetDlgItemText(hDlg, IDASK_PARAMS, szBuffer, MAXFILECHARS-1);
  207.             EndDialog(hDlg, 0);
  208.             return TRUE;
  209.  
  210.         case IDASK_CANCEL:
  211.             EndDialog(hDlg, 0);
  212.             strcpy(szBuffer, "  ");
  213.             // ProgExec() will not start the program
  214.             bExecuteProg = FALSE;
  215.             return TRUE;
  216.         }
  217.         break;
  218.     }
  219.     return FALSE;
  220.     }
  221.